package com.alvin.mbp.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.alvin.mbp.entity.PointMember;
import com.alvin.mbp.entity.PointRecord;
import com.alvin.mbp.service.PointRecordService;

@Controller
public class HomeAction {

	@Autowired
	private PointRecordService pointRecordService;

	@RequestMapping(value = "/home.htm", method = RequestMethod.GET)
	public String home(Model model, HttpServletRequest request) {

		PointMember member = (PointMember) request.getSession().getAttribute("MEMBER");
		List<PointRecord> records = pointRecordService.findByProperty("member_id", member.getId());
		model.addAttribute("records", records);

		return "/home";
	}

}
